package com.persistence;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="t_football_team")
public class TFootballTeam implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer idTeam;
	private String teamName;
	private List<TPlayer> TPlayers;
	private List<TPlayer> captains;
//	private List<TCaptain> TCaptains;
	
	@OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinTable(name="t_captain",
	joinColumns = {@JoinColumn(name="team_id")},
	inverseJoinColumns = {@JoinColumn(name="player_id")})
	public List<TPlayer> getCaptains() {
		return captains;
	}

	public void setCaptains(List<TPlayer> captains) {
		this.captains = captains;
	}

	public TFootballTeam() {
	}
	
	@Id
	@Column(name="id_team", unique=true, nullable=false)
	public Integer getIdTeam() {
		return idTeam;
	}

	public void setIdTeam(Integer idTeam) {
		this.idTeam = idTeam;
	}

	@Column(name="team_name", nullable=false)
	public String getTeamName() {
		return teamName;
	}

	public void setTeamName(String teamName) {
		this.teamName = teamName;
	}

	@OneToMany(mappedBy="TFootballTeam", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
	public List<TPlayer> getTPlayers() {
		return TPlayers;
	}

	public void setTPlayers(List<TPlayer> tPlayers) {
		TPlayers = tPlayers;
	}
	
//	@OneToMany(mappedBy="TFootballTeam", fetch=FetchType.EAGER, cascade=CascadeType.ALL)
//	public List<TCaptain> getTCaptains() {
//		return this.TCaptains;
//	}
//
//	public void setTCaptains(List<TCaptain> TCaptains) {
//		this.TCaptains = TCaptains;
//	}
}
